home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: gast@pc5772.hil.siemens.at (Gastkennung am pc5772)
- Newsgroups: comp.lang.c,comp.lang.c.moderated,comp.os.ms-windows.programmer.misc
- Subject: Re: Text representation of a number...
- Date: 21 Feb 1996 08:56:18 -0600
- Organization: Siemens AG Austria
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4gfbqi$27r@solutions.solon.com>
- References: <4fjm7r$odb@solutions.solon.com> <4fu8ek$9lp@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- : Joel York (yorkjoe@elof.acc.iit.edu) wrote:
- : : Greetings.
- : : I'm in need of an algorithm to take an eight-byte integer (not supported
- : : as a native type in Windows 3.1), and print its ASCII representation
- : : to a file. This number comes from a server that stores the number in
- : : big-endian format, but I could switch it if necessary. If anyone
- : : knows such an algorithm, or has a pointer to one, it'd be much
- : : appreciated.
- i fear you wont get around defining the operation "div 10"
- and "mod 10" on your longish integer type. Once you have that,
- you can repeatedly use x mod 10 as the next decimal digit and then
- replace x by (x div 10) until x is zero.
- this will yield the decimal representation in reverse order (least
- significant digit first), but stringreversal shouldn't be a problem.
-
- remains the problem of div'ing(mod'ing) your number-representation.
- you'll have to build it using the / and % of smaller integertypes. (not
- really easy, but it's possible)
- have a look on how you divide big numbers by hand (on paper), and then
- try to re-implement that algorithm.
- --
- gast@pc5772.hil.siemens.co.at (Andreas Leitgeb)
- /* Hereby i grant you my non-exclusive permission to share my opinions */
-